/**
* ...
* @author Default
* @version 0.1
*/
package net.roading.mvc.control
{
	import flash.events.IEventDispatcher;
	import flash.events.EventDispatcher;
	public class Dispatcher 
	{
		
		private static var instance : Dispatcher;  
		private var eventDispatcher : IEventDispatcher;
		/**
		* Returns the single instance of the dispatcher
		*/ 
		public static function getInstance() : Dispatcher 
		{
		 if ( instance == null )
			instance = new Dispatcher();
		  
		   return instance;
		}

		/**
		* Constructor.
		*/
		public function Dispatcher( target:IEventDispatcher = null ) 
		{
			eventDispatcher = new EventDispatcher( target );
		}

		/**
		* Adds an event listener.
		*/
		public function addEventListener( type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false ) : void 
		{
			eventDispatcher.addEventListener( type, listener, useCapture, priority, useWeakReference );
		}

		/**
		* Removes an event listener.
		*/
		public function removeEventListener( type:String, listener:Function, useCapture:Boolean = false ) : void 
		{
			eventDispatcher.removeEventListener( type, listener, useCapture );
		}

		/**
		* Dispatches a cairngorm event.
		*/
		public function dispatchEvent( event:MvcEvent ) : Boolean 
		{
			return eventDispatcher.dispatchEvent( event );
		}

		/**
		* Returns whether an event listener exists.
		*/
		public function hasEventListener( type:String ) : Boolean 
		{
			return eventDispatcher.hasEventListener( type );
		}

		/**
		* Returns whether an event will trigger.
		*/
		public function willTrigger(type:String) : Boolean 
		{
			return eventDispatcher.willTrigger( type );
		}
		
	}
}